<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 数组解构赋值
        let arr = [11, 22, 33, 44]
        // let b=arr[1]
        // let a=arr[0]
        let [a, b, ...c] = [11, 22, 33, 44]
        console.log(a, b, c);
        let [[d, e], [f, [g], [h]]] = [[11, 22], [33, [44], [55]]]
        console.log(d, e, f, g, h);
        //对象解构赋值
        let obj = { "name": "my", "age": 18 }
        // let name=obj.name;
        // let age=obj.age
        //别名：=默认值
        let { name: n, age, sex = "女" } = { "name": "my", "age": 18 }
        console.log(n, age, sex);
        //交换变量值
        let x = 1;
        let y = 2;
        let z;
        z = x;
        x = y;
        y = z;
        //冒泡排序
        [y, x] = [x, y]
        console.log(x, y);
    </script>
</body>

</html>